
PREFIX := aarch64-linux-gnu-

CC := $(PREFIX)gcc
LD := $(PREFIX)ld
ARMCC := armclang --target=aarch64-arm-none-eabi -march=armv8.3-a+sve
# OBJDUMP := fromelf -c
OBJDUMP := llvm-objdump -mattr=+sve -d

all: clean test_fn


.PHONY : all
.PHONY : clean
.PHONY : tmp_fn

tmp_fn: clean _tmp_fn

_tmp_fn: tmp_fn.ao out_p.o exception.o
	$(LD) -Ttmp_fn.lds $^ -o tmp_fn.elf
	$(LD) -Tfvp_tmp_fn.lds $^ -o fvp_tmp_fn.elf
	$(OBJDUMP) tmp_fn.elf > tmp_fn.asm
	
test_fn: test_fn.ao out_p.o
	$(LD) -T$@.lds $^ -o $@.elf
	$(OBJDUMP) $@.elf > $@.asm

switch_el: switch_el.o out_p.o
	$(LD) -T$@.lds $^ -o $@.elf
	$(OBJDUMP) $@.elf > $@.asm

test_addr: sub_test/test_addr_br.o test_addr.o
	$(LD) -T$@.lds $^ -o $@.elf
	$(OBJDUMP) $@.elf > $@.asm

%.ao: %.S
	$(ARMCC) -c $^ -o $@
%.o: %.S
	$(CC) -c $^ -o $@

clean:
	touch *.{ao,o,elf,asm}
	rm *.{ao,o,elf,asm}
	